package 双指针;

public class 和为s的两个数字6 {
    //https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/
    public int[] twoSum(int[] price, int target) {
        int left = 0, right = price.length - 1;
        while(left < right) {
            if(price[left] + price[right] > target) {
                right--;
            }else if(price[left] + price[right] < target) {
                left++;
            }else {
                return new int[] {price[left],price[right]};
            }
        }
        return null;
    }
}
